
* -------------------------------------------------------- *
* Table A1: Summary Statistics by Interview Day Attendance *
* -------------------------------------------------------- *


local Xind "gpa undergrad_satmt75   major_socialScience major_mathScience major_humanities doubleMajor yearsSinceCollege_1_2 yearsSinceCollege_3_5 yearsSinceCollege_6p female black hispanic otherRace"

clear
use ${data}teacher_data.dta
keep if (CorpsYear==2013 | CorpsYear==2014) & !missing(hs) & region==1

matrix sumstats = J(14,8,.)
local row=0
local col=0


foreach var of varlist `Xind' {
	local row=`row'+1
	local col=1
	su  `var' if intDayAttend==1 & CorpsYear==2013 & hs==1
	matrix sumstats[`row',`col'] = r(mean)
	local col=`col'+1
	su  `var' if intDayAttend==0 & CorpsYear==2013 & hs==1
	matrix sumstats[`row',`col'] = r(mean)
	local col=`col'+1
	su  `var' if intDayAttend==1 & CorpsYear==2014 & hs==1
	matrix sumstats[`row',`col'] = r(mean)
	local col=`col'+1
	su  `var' if intDayAttend==0 & CorpsYear==2014 & hs==1
	matrix sumstats[`row',`col'] = r(mean)
	local col=`col'+1	
	su  `var' if intDayAttend==1 & CorpsYear==2013 & hs==0
	matrix sumstats[`row',`col'] = r(mean)
	local col=`col'+1
	su  `var' if intDayAttend==0 & CorpsYear==2013 & hs==0
	matrix sumstats[`row',`col'] = r(mean)
	local col=`col'+1
	su  `var' if intDayAttend==1 & CorpsYear==2014 & hs==0	
	matrix sumstats[`row',`col'] = r(mean)
	local col=`col'+1
	su  `var' if intDayAttend==0 & CorpsYear==2014 & hs==0
	matrix sumstats[`row',`col'] = r(mean)

}

* Sample sizes
local row=`row'+1
local col=1
su  `var' if intDayAttend==1 & CorpsYear==2013 & hs==1
matrix sumstats[`row',`col'] = r(N)
local col=`col'+1
su  `var' if intDayAttend==0 & CorpsYear==2013 & hs==1
matrix sumstats[`row',`col'] = r(N)
local col=`col'+1
su  `var' if intDayAttend==1 & CorpsYear==2014 & hs==1
matrix sumstats[`row',`col'] = r(N)
local col=`col'+1
su  `var' if intDayAttend==0 & CorpsYear==2014 & hs==1
matrix sumstats[`row',`col'] = r(N)
local col=`col'+1
	
count if intDayAttend==1 & CorpsYear==2013 & hs==0
matrix sumstats[`row',`col'] = r(N)
local col=`col'+1
su  `var' if intDayAttend==0 & CorpsYear==2013 & hs==0
matrix sumstats[`row',`col'] = r(N)
local col=`col'+1
su  `var' if intDayAttend==1 & CorpsYear==2014 & hs==0	
matrix sumstats[`row',`col'] = r(N)
local col=`col'+1
su  `var' if intDayAttend==0 & CorpsYear==2014 & hs==0
matrix sumstats[`row',`col'] = r(N)
local col=`col'+1


	
	
clear
svmat sumstats
gen label = ""
local row=0
foreach var in `Xind' {
	local row=`row'+1
	replace label = "`var'" in `row'
}
local row=`row'+1
replace label = "N" in `row'
outsheet using ${results}tableA1.csv, comma names replace




 
* -------------------------------------------------------------- *
* Table A2: Interview Day Attendance and Teacher Characteristics *
* -------------------------------------------------------------- *


* Update macro for regression (add in missing indicator)
local Xind2 "gpa undergrad_satmt75    major_socialScience major_mathScience major_humanities doubleMajor yearsSinceCollege_1_2 yearsSinceCollege_3_5 yearsSinceCollege_6p female black hispanic otherRace undergrad_sat_ms"

clear
use ${data}teacher_data.dta
keep if (CorpsYear==2013 | CorpsYear==2014) & !missing(hs) & region==1

replace undergrad_satmt75 = undergrad_satmt75/100

eststo clear
eststo pool: reg intDayAttend `Xind2' i.CorpsYear i.hs, robust
test `Xind2'
estadd scalar p = r(p): pool
test gpa undergrad_satmt75 undergrad_sat_ms   major_socialScience major_mathScience major_humanities doubleMajor yearsSinceCollege_1_2 yearsSinceCollege_3_5 yearsSinceCollege_6p female  
estadd scalar p2 = r(p): pool

eststo hs13: reg intDayAttend `Xind2' if CorpsYear==2013 & hs==1, robust
test `Xind2'
estadd scalar p = r(p): hs13
test gpa undergrad_satmt75 undergrad_sat_ms   major_socialScience major_mathScience major_humanities doubleMajor yearsSinceCollege_1_2 yearsSinceCollege_3_5 yearsSinceCollege_6p female  
estadd scalar p2 = r(p): hs13

eststo hs14: reg intDayAttend `Xind2' if CorpsYear==2014 & hs==1, robust
test `Xind2'
estadd scalar p = r(p): hs14
test gpa undergrad_satmt75 undergrad_sat_ms   major_socialScience major_mathScience major_humanities doubleMajor yearsSinceCollege_1_2 yearsSinceCollege_3_5 yearsSinceCollege_6p female  
estadd scalar p2 = r(p): hs14

eststo elem13: reg intDayAttend `Xind2' if CorpsYear==2013 & hs==0, robust
test `Xind2'
estadd scalar p = r(p): elem13
test gpa undergrad_satmt75 undergrad_sat_ms   major_socialScience major_mathScience major_humanities doubleMajor yearsSinceCollege_1_2 yearsSinceCollege_3_5 yearsSinceCollege_6p female  
estadd scalar p2 = r(p): elem13

eststo elem14: reg intDayAttend `Xind2' if CorpsYear==2014 & hs==0, robust
test `Xind2'
estadd scalar p = r(p): elem14
test gpa undergrad_satmt75 undergrad_sat_ms   major_socialScience major_mathScience major_humanities doubleMajor yearsSinceCollege_1_2 yearsSinceCollege_3_5 yearsSinceCollege_6p female  
estadd scalar p2 = r(p): elem14

  estout pool hs13 hs14 elem13 elem14  ///
  using ${results}tableA2.txt, replace ///
	keep(`Xind2') cells(b(star fmt(3) nostar)  se(par fmt(3))) ///
	collabels(,none) stat(p p2 N)  	
	
	
* ----------------------------------------- *
* Table A5: Attendance at DA Interview Days *
* ----------------------------------------- *

clear
use ${data}preference_data.dta
drop if outside_cm==1 | outside_sch==1

* Expand so one row per position
gen row=_n
expand NumberPositions
sort schoolcert_id row
by schoolcert_id row: gen pos = _n
drop row
egen schoolpos_id = group(schoolcert_id pos)

matrix attend = J(3,3,.)

forv d=1/3 {
	* Teachers
	unique teacher_id if intDay==`d'
	matrix attend[`d',1] = r(unique)
	* Schools
	unique school_id if intDay==`d'
	matrix attend[`d',2] = r(unique)
	* School positions
	unique schoolpos_id if intDay==`d'
	matrix attend[`d',3] = r(unique)
}

clear
svmat attend
ren attend1 teachers
ren attend2 schools
ren attend3 positions
gen label = ""
 replace label = "Day 1" in 1
 replace label = "Day 2" in 2
 replace label = "Day 3" in 3
 
outsheet using ${results}tableA3.csv, comma names replace	
	
	
exit
